class NumArray(object):
    def __init__(self, nums):
        """
        :type nums: List[int]
        """
        self.sum_map = {-1: 0}
        for (i, n) in enumerate(nums):
            self.sum_map[i] = self.sum_map[i - 1] + n

    def sumRange(self, i, j):
        """
        :type i: int
        :type j: int
        :rtype: int
        """
        return self.sum_map[j] - self.sum_map[i - 1]


# Your NumArray object will be instantiated and called as such:
# obj = NumArray(nums)
# param_1 = obj.sumRange(i,j)

obj = NumArray([-2, 0, 3, -5, 2, -1])
print(obj.sumRange(0, 2))